package com.ihome.android.market2.info;

import java.util.ArrayList;
import java.util.List;

import android.os.Parcel;
import android.os.Parcelable;


public class AppDetailInfo implements Parcelable {

	/** 应用 ID */
	private int					appId;
	/** 应用名称 */
	private String				appName;
	/** 应用图标 */
	private String				iconUrl;
	/** 价格单位 */
	private String				priceUnit;
	/** 价格（订购类型：如果是单次：x 元/次；如果是包月：x 元/月） */
	private double				price;
	/** 优惠价格（订购类型：如果是单次：x 元/次；如果是包月：x 元/月） */
	private double				discountPrice;
	/** 应用评分 */
	private double				rate;
	/** 下载次数 */
	private int					downNum;
	/** 软件大小 */
	private String				apkFileSize;
	/** 掌柜昵称 */
	private String				shopkeeper;
	/** 客户端不显示即可 */
	private String				sameAppVersion;
	/** 应用简介 */
	private String				synopsis;
	/** 预览图片 */
	private String				preview;
	/** 所属店铺 ID */
	private int					storeId;
	/** 掌柜 ID */
	private int					shopkeeperId;
	/** 同系列应用的版本 ID 集合（以逗号分隔）客户端不显示即可 */
	private String				sameAppVersionId;
	/** 适用操作系统 */
	private String				osList;
	/** 语言 */
	private String				lang;
	/** 版本号 */
	private String				version;
	/** 发布日期 */
	private String				addTime;
	/**
	 * 适配机型(不同品牌按'|'分隔，品牌内机型按','分隔,品牌和机型 按':'分隔)
	 */
	private String				machineList;
	/** 收藏人气 */
	private int					collectCount;
	/** 是否参加专题促销 */
	private boolean				isTopicApp;
	/** 促销总数量 */
	private int					goodsNum;
	/** 促销剩余数量 */
	private int					goodsLastNum;
	/** 促销当天的剩余时间(毫秒数,如果结束返回 0) */
	private int					endTime;
	/** 促销详情介绍 */
	private String				topicIntro;
	/** 应用分类 id */
	private int					categoryId;
	/** 应用分类名称 */
	private String				CLSName;
	/** 当前客户端是否已经收藏 */
	private boolean				isMyFavourite;
	/** 当前客户端评分状态：0:未下载，未评分；1：已下载，未评分；2：已评分 */
	private int					rateStatus;
	/** 是否已购买 */
	private boolean				bought;
	/** 包含改App的所有产品包 */
	private List<ProductInfo>	productList = new ArrayList<ProductInfo>();

	private int					recomCount;
	private int					delete	= 0;
	private String				productID;
	private String				packageName;
	
	
	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeInt(appId);
		dest.writeString(appName);
		dest.writeString(iconUrl);
		dest.writeString(priceUnit);
		dest.writeDouble(price);
		dest.writeDouble(discountPrice);
		dest.writeDouble(rate);
		dest.writeInt(downNum);
		dest.writeString(apkFileSize);
		dest.writeString(shopkeeper);
		dest.writeString(sameAppVersion);
		dest.writeString(synopsis);
		dest.writeString(preview);
		dest.writeInt(storeId);
		dest.writeInt(shopkeeperId);
		dest.writeString(sameAppVersionId);
		dest.writeString(osList);
		dest.writeString(lang);
		dest.writeString(version);
		dest.writeString(addTime);
		dest.writeString(machineList);
		dest.writeInt(collectCount);
		dest.writeTypedList(productList == null? new ArrayList<ProductInfo>():productList);
		
	}

	public AppDetailInfo(Parcel source) {
		this.appId = source.readInt();
		this.appName = source.readString();
		this.iconUrl = source.readString();
		this.priceUnit = source.readString();
		this.price = source.readDouble();
		this.discountPrice = source.readDouble();
		this.rate = source.readDouble();
		this.downNum = source.readInt();
		this.apkFileSize = source.readString();
		this.shopkeeper = source.readString();
		this.sameAppVersion = source.readString();
		this.synopsis = source.readString();
		this.preview = source.readString();
		this.storeId = source.readInt();
		this.shopkeeperId = source.readInt();
		this.sameAppVersionId = source.readString();
		this.osList = source.readString();
		this.lang = source.readString();
		this.version = source.readString();
		this.addTime = source.readString();
		this.machineList = source.readString();
		this.collectCount = source.readInt();
		source.readTypedList(productList, ProductInfo.CREATOR);
	}

	@Override
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append("appId      		= ").append(appId).append("\n");
		sb.append("productID      = ").append(productID).append("\n");
		sb.append("appName        = ").append(appName).append("\n");
		sb.append("price          = ").append(price).append("\n");
		sb.append("bought         = ").append(bought).append("\n");
		if (productList != null && productList.size() > 0) {
			sb.append("productList    = ").append(productList.get(0).toString()).append("\n");
		}
		else {
			sb.append("productList    = ").append("NULL").append("\n");
		}

		return sb.toString();
	}

	public int getAppId() {
		return appId;
	}

	public void setAppId(int appId) {
		this.appId = appId;
	}

	public String getAppName() {
		return appName.replaceAll("\\s*", "");
	}

	public void setAppName(String appName) {
		this.appName = appName;
	}

	public String getIconUrl() {
		return iconUrl;
	}

	public void setIconUrl(String iconUrl) {
		this.iconUrl = iconUrl;
	}

	public String getPriceUnit() {
		return priceUnit;
	}

	public void setPriceUnit(String priceUnit) {
		this.priceUnit = priceUnit;
	}

	public double getPrice() {
		if(discountPrice > 0){
			return discountPrice;
		}
		return price;
	}

	public void setPrice(int price) {
		this.price = price;
	}

	public double getDiscountPrice() {
		return discountPrice;
	}

	public void setDiscountPrice(double discountPrice) {
		this.discountPrice = discountPrice;
	}

	public double getRate() {
		return rate;
	}

	public void setRate(double rate) {
		this.rate = rate;
	}

	public int getDownNum() {
		return downNum;
	}

	public void setDownNum(int downNum) {
		this.downNum = downNum;
	}

	public String getApkFileSize() {
		return apkFileSize;
	}

	public void setApkFileSize(String apkFileSize) {
		this.apkFileSize = apkFileSize;
	}

	public String getShopkeeper() {
		return shopkeeper;
	}

	public void setShopkeeper(String shopkeeper) {
		this.shopkeeper = shopkeeper;
	}

	public String getSameAppVersion() {
		return sameAppVersion;
	}

	public void setSameAppVersion(String sameAppVersion) {
		this.sameAppVersion = sameAppVersion;
	}

	public String getSynopsis() {
		return synopsis;
	}

	public void setSynopsis(String synopsis) {
		this.synopsis = synopsis;
	}

	public String getPreview() {
		return preview;
	}

	public void setPreview(String preview) {
		this.preview = preview;
	}

	public int getStoreId() {
		return storeId;
	}

	public void setStoreId(int storeId) {
		this.storeId = storeId;
	}

	public int getShopkeeperId() {
		return shopkeeperId;
	}

	public void setShopkeeperId(int shopkeeperId) {
		this.shopkeeperId = shopkeeperId;
	}

	public String getSameAppVersionId() {
		return sameAppVersionId;
	}

	public void setSameAppVersionId(String sameAppVersionId) {
		this.sameAppVersionId = sameAppVersionId;
	}

	public String getOsList() {
		return osList;
	}

	public void setOsList(String osList) {
		this.osList = osList;
	}

	public String getLang() {
		return lang;
	}

	public void setLang(String lang) {
		lang = lang;
	}

	public String getVersion() {
		return version;
	}

	public void setVersion(String version) {
		this.version = version;
	}

	public String getAddTime() {
		return addTime;
	}

	public void setAddTime(String addTime) {
		this.addTime = addTime;
	}

	public String getMachineList() {
		return machineList;
	}

	public void setMachineList(String machineList) {
		this.machineList = machineList;
	}

	public int getCollectCount() {
		return collectCount;
	}

	public void setCollectCount(int collectCount) {
		this.collectCount = collectCount;
	}

	public boolean isTopicApp() {
		return isTopicApp;
	}

	public void setTopicApp(boolean isTopicApp) {
		this.isTopicApp = isTopicApp;
	}

	public int getGoodsNum() {
		return goodsNum;
	}

	public void setGoodsNum(int goodsNum) {
		this.goodsNum = goodsNum;
	}

	public int getGoodsLastNum() {
		return goodsLastNum;
	}

	public void setGoodsLastNum(int goodsLastNum) {
		this.goodsLastNum = goodsLastNum;
	}

	public int getEndTime() {
		return endTime;
	}

	public void setEndTime(int endTime) {
		this.endTime = endTime;
	}

	public String getTopicIntro() {
		return topicIntro;
	}

	public void setTopicIntro(String topicIntro) {
		this.topicIntro = topicIntro;
	}

	public int getCategoryId() {
		return categoryId;
	}

	public void setCategoryId(int categoryId) {
		this.categoryId = categoryId;
	}

	public String getClsName() {
		return CLSName;
	}

	public void setClsName(String clsName) {
		this.CLSName = clsName;
	}

	public boolean getIsMyFavourite() {
		return isMyFavourite;
	}

	public void setIsMyFavourite(boolean isMyFavourite) {
		this.isMyFavourite = isMyFavourite;
	}

	public int getRateStatus() {
		return rateStatus;
	}

	public void setRateStatus(int rateStatus) {
		this.rateStatus = rateStatus;
	}

	public boolean isBought() {
		return bought;
	}

	public void setBought(boolean bought) {
		this.bought = bought;
	}

	public List<ProductInfo> getProductList() {
		return productList;
	}

	public void setProductList(List<ProductInfo> productList) {
		this.productList = productList;
	}

	public int getRecomCount() {
		return recomCount;
	}

	public void setRecomCount(int recomCount) {
		this.recomCount = recomCount;
	}

	public int getDelete() {
		return delete;
	}

	public void setDelete(int delete) {
		this.delete = delete;
	}

	public String getProductID() {
		return productID;
	}

	public void setProductID(String productId) {
		this.productID = productId;
	}

	public String getPackageName() {
		return packageName;
	}

	public void setPackageName(String packageName) {
		this.packageName = packageName;
	}

	@Override
	public int describeContents() {
		return 0;
	}


	public static final Parcelable.Creator<AppDetailInfo>	CREATOR	= new Parcelable.Creator<AppDetailInfo>() {

																	@Override
																	public AppDetailInfo createFromParcel(Parcel source) {
																		return new AppDetailInfo(source);
																	}

																	@Override
																	public AppDetailInfo[] newArray(int size) {
																		return new AppDetailInfo[size];
																	}

																};

}
